<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.lavegue.model.Area" %>
  <head>
    <base href="<%=basePath%>" />
    
    <title>修改用户信息</title>
    <script type='text/javascript' src='dwr/interface/userdwr.js'></script>
     <script type='text/javascript' src='dwr/interface/areadwr.js'></script>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type='text/javascript' src='js/jquery.validate.min.js'></script>
 	<script type='text/javascript' src='js/common.js'></script>
	<meta http-equiv="pragma" content="no-cache" />
	<script type='text/javascript' src='<%=basePath %>/dwr/engine.js'></script>
 	<script type='text/javascript' src='<%=basePath %>/dwr/util.js'></script>
	<link href="images/css.css"  rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.STYLE13 {color: #A3A3A3}
-->
</style>

<script type="text/javascript">

function checkValid(){
		//所在地
		var province = $.trim($("#province").val()); //获取省份值
		var city = $.trim($("#city").val()); //获取市区值
		var area = $.trim($("#area").val()); //获取区域值
		
		var userEmail = $.trim($("#email").val());  //email
		var userQq = $.trim($("#userQq").val());  //QQ
		var individualUrl=$.trim($("#personalHonepage").val());  //个人主页网址
		var personalIntro = $.trim($("#personalIntro").val());  //个人介绍
		var filePath = $.trim($("#picFilePath").val());  //图片路径
		var fname = $.trim($("#pic").val());
		
		if(province==0){// || city==0 || area==0
			$("#areaSpan").html("请选择所在地区.");
			return false;
		}else{
			$("#areaSpan").html("");
			//设置隐藏域的值
			$("#userProvince").val(province);
			
		//	var  pp = $.trim($("#userProvince").val());
		//	var  City = $.trim($("#userCity").val());
		//	alert("Province="+pp+",city="+City);
		}			
		
		if(city != 0){
			$("#userCity").val(city);
		}
		if(area != 0){
			$("#userZone").val(area);
		}
		
		//效验email
		if(userEmail !=""){
			//	alert("email=>"+isValidEmail(userEmail));
			if(!isValidEmail(userEmail)){
				$("#emailSpan").html("&nbsp;输入的E_Mail格式有误.");
				$("#userEmail").select();
				return false;
			}else{
				$("#emailSpan").html("");
			}
			$("#emailSpan").html("");
		}
		//效验QQ
		if(userQq != ""){
			//----以下是效验QQ
			if(!isValidQQ(userQq)){
					$("#qqSpan").html("&nbsp;输入的QQ号码有误.");
					$("#userQq").select();
					return false;
			}else{
				$("#qqSpan").html("");
			}
			$("#qqSpan").html("");
		}
		//效验个人主页网址
		if(individualUrl != ""){
			if(!isUrl(individualUrl)){
				$("#individualSpan").html("&nbsp;个人主页格式有误.");
				$("#personalHonepage").select();
				return false;
			}else{
				$("#individualSpan").html("");
			}
			$("#individualSpan").html("");
		}
		//个人简介
		if(personalIntro != ""){
			if(personalIntro.length > 1000){
				$("#personalIntroSpan").html("&nbsp;个人简介不能超过1000个字符.");
				return false;
			}else{
				$("#personalIntroSpan").html("");
			}
			$("#personalIntroSpan").html("");
		}
					
	//	$("#picFilePath").val(filePath); //设置图片路径隐藏域的值
	return true;

}

function isZiMu_Num(str) {
	//var voidChar = /[@#\$%\^&\*]+/g;
	var voidChar = /^[A-Za-z0-9_]+$/g;
	
	return voidChar.test(str);
}
/**
 * 判断是不是有效的手机号码
 * 格式正确返回true,否则false.
 */
function isValidMobile(mobile) {
    //var pattern = /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/;
    var pattern = /^((13[0-9]{1}|15[0-9]{1}|18[0-9]{1}|)+\d{8})$/;   
    return pattern.test(mobile);
}
/**
 * 判断是不是有效的电话号码
 * 格式正确返回true,否则false.
 */
function isValidTelPhone(telphone) {
    var pattern = /^((\d{3,4})|(\d{3,4}-))?\d{7,8}$/;
    return pattern.test(telphone);
}
/**
 * 判断是不是有效的email地址
 */
function isValidEmail(vEMail) {
	var regInvalid = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!regInvalid.test(vEMail)){
		return false;
	}
	return true; 
}
/**
 * 判断是不是有效的QQ
 * 格式正确返回true,否则false.
 */
function isValidQQ(qq){
	var exgQQ = /^[1-9]\d{4,11}$/;
	return exgQQ.test(qq);
}

/**
 * 判断是不是有效的邮政编码;
 * 格式正确返回true,否则false.
 */
function isValidZipcode(code) {
    var pattern = /^\d{6}$/;
    if (!pattern.test(code)) {
        return false;
    }
    return true;
}
/**
 * 判断是不是有效的汉字
 */
function checkIsChinese(str) {
    //正则表达式 /^[\u0391-\uFFE5]+$/
    var pattern = /[^\u4E00-\u9FA5]/g;
    if (pattern.test(str)) {
        return false;
    }
    return true;
}
function isUrl(str){
var Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; 
var expURL=  /^([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?$/; 
//var objExp=new RegExp("([^(http://|http:\\)])((www|cn)[.](\w)+[.]{1,}(net|com|cn|org|cc)(((\/[\~]*|\\[\~]*)(\w)+)|[.](\w)+)*(((([?](\w)+){1}[=]*))*((\w)+){1}([\&](\w)+[\=](\w)+)*)*)")
//var objExp=/([^(http://|http:\\)])((www|cn)[.](\w)+[.]{1,}(net|com|cn|org|cc)(((\/[\~]*|\\[\~]*)(\w)+)|[.](\w)+)*(((([?](\w)+){1}[=]*))*((\w)+){1}([\&](\w)+[\=](\w)+)*)*)/;

   return (Expression.test(str)==true || expURL.test(str)==true)?true:false;
}
/**
 * 验证输入的字符是否包含@#$%^&*:|+)(!~=}{;?>`<'非法字符
 * 如果返回true为包含,false不包含非法字符
 */	
function isIllegalChar(str) {
	var voidChar = /[@#\$%\^&\*\+\?:|.!~=>`<]+/g;
	return voidChar.test(str);
}
function isCurrency(currency){
 	var curr = /^\d+(\.\d+)?$/;
 	return curr.test(currency);
} 
function isNumber(num){
 	var number = /^\d+$/;
 	return number.test(num);
} 

//省份按钮事件
function changeProvinceHandler() {
	//获取省份下拉框的值
	var province = $("#province").val();
	//如果选择了"请选择这个项" (0表示选择了这个项)
	if (province == 0) {
		//删除市和区域下拉的全部选项
		DWRUtil.removeAllOptions("city");
		DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 
				
	//删除市下拉的全部选项
	DWRUtil.removeAllOptions("city");
	//根据所选择的省从后台获取相关的市
	areadwr.findAreaByParendIdAndlvType(province, <%= Area.AreaType.CITY%>, function(data){
	DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("city", data, "id", "name");   //把data数据填充到城市下拉框
	DWRUtil.removeAllOptions("area");   //清除区域的初始值
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择" }], "id", "name");
	});
}

//城市按钮事件
function changeCityHandler() {
	var city = $("#city").val();
	//如果选择了"请选择这个项"
	if (city == 0) {
		//删除区下拉的全部选项
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 
				
	//删除区域下拉的全部选项
	DWRUtil.removeAllOptions("area");
	//根据所选择的市从后台获取相关的区
	areadwr.findAreaByParendIdAndlvType(city, <%= Area.AreaType.AREA%>, function(data) {
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("area", data, "id", "name"); //把data数据填充到区域下拉框
	});
}

//表单提交
function modifyUserInfo(){
	if(!checkValid()){
		return false;
	}else{
		//表单提交
	    $("#modUserInfo").submit();
	}
}

function quXiao(){
	window.location.href='userRegister!toShowUserInfoPage.action';
}
//弹出对话框
function openPage(url)
{
	var r=parseInt(Math.random()*1000);
	window.showModalDialog(url,window,'status:no;help:no;dialogHeight:160px; dialogWidth:400px');
}

</script>
<script type="text/javascript">
	function uploadSubmit(){
		var fname = $.trim($("#pic").val());
//		alert("文件名==="+fname);
//		var subName = fname.substring(fname.lastIndexOf("\")+1, fname.lastIndexOf(".")+4);
//		$("#picFileName").val(subName);
//		alert("文件名==="+subName);
		//表单提交
//		alert($("#addForm"));
		if(fname == ""){
			$("#logoSpan").html("请选择您要上传的图片.");
			return false;
		}else
		{
			
			//从最后一个点开始,截取3三个字符
			var subName = fname.substr(fname.lastIndexOf(".")+1,3);
		//	alert("图片类型："+subName);
			if(subName.toUpperCase() != "JPG" && subName.toUpperCase() != "GIF"){
				$("#logoSpan").html("您上传的文件类型不正确,请重新选择.");
				return false;
			}
			
			$("#logoSpan").html("");
		}
		//所在地区的值
		var province = $.trim($("#province").val()); //获取省份值
		var city = $.trim($("#city").val()); //获取市区值
		var area = $.trim($("#area").val()); //获取区域值
		var balance = $.trim($("#balance").val());   //充值金额
		
		if(province != 0){
			$("#userProvince").val(province);
			
		//	var  pp = $.trim($("#userProvince").val());
		//	alert("Province="+pp);
		}		
		if(city !=0 ){
			$("#userCity").val(city);
		//	alert("city="+city);
		}
		if(area != 0){
			$("#userZone").val(area);
		//	alert("area="+area);
		}
	    document.modUserInfo.action ="companyLogoUpload!uploadEnterpriseLogo.action";
		document.modUserInfo.submit();
	}

</script>
  </head>
  
<body>

	<s:form action="userRegister!doModUserInfo.action" name="modUserInfo" id="modUserInfo" enctype="multipart/form-data" method="post">
		<table width="789" height="539" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
  <tr>
    <td width="789" height="39" align="left" valign="middle"><span class="STYLE1">&nbsp;<a href="javascript:void(parent.window.location.href='loginAction!login.action')" class="STYLE1">我的易彩通</a> &gt; 我的账号 &gt; 我的名片</span></td>
  </tr>
  <tr>
    <td height="500" align="center" valign="top" bgcolor="#FFFFFF" style="border:1px solid #C5C5C5; padding:1px ;">
    <table width="100%" height="32" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" height="32" background="images/sp_bg.jpg">&nbsp;</td>
        <td width="3%" align="center" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><img src="images/dian.jpg" width="10" height="16" /></td>
        <td width="95%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><span class="STYLE3">基本信息</span></td>
        <td width="1%" background="images/sp_bg.jpg">&nbsp;</td>
      </tr>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="8">&nbsp;</td>
        </tr>
      </table>
      
      <table width="775" height="436" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="325" height="38" align="center">&nbsp;</td>
          <td width="450" align="left" valign="top">&nbsp;</td>
        </tr>
        <tr>
 <%--   <form name="addForm" id="addForm" action="companyLogoUpload!uploadEnterpriseLogo.action" enctype="multipart/form-data" method="post"> --%>
          <td height="307" align="center" valign="top">
                    
          <%-- 如果session中用户对象有数据就显示对象中的图片路径，不存在就显示默认图片 --%>
		   <s:if test="#session.userObject.personalIco != null && #session.userObject.personalIco !='' && #session.imgIcoPath == null">
		          <img src='<s:property value="#session.userObject.personalIco"/>' width="224" height="195" />
		   </s:if>
		   <s:else>
		   		<%-- 如果请求中imgIcoPath对象有数据就显示对象中的图片路径，不存在就显示默认图片 --%>
		   		 <s:if test="#session.imgIcoPath != null && #session.imgIcoPath !=''">
		   		 	<img src='<s:property value="#session.imgIcoPath"/>' width="224" height="195" />
		   		 </s:if>
		   		 <s:else>
		   		 	 <img src='images/default_pic.gif' width="224" height="195" />
		   		 </s:else>
		          
		   </s:else>
          
            <table width="242" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #DEDEDE;">
              <tr>
                <td height="20" align="center">
             <%-- <a style="cursor:pointer;" onclick="openPage('upload_logo.jsp')">更改照片</a>
             		<div align="left">
						<s:include value="upload_logo.jsp" />
					</div>--%>
					
				
		<table border="0" align="center" cellpadding="0" cellspacing="0" class="gxzp">
			  <tr>
			    <td width="46" height="25" align="left" valign="middle"  class="gxzp1">&nbsp;&nbsp;</td>
			    <td width="538" align="left" valign="middle"  class="gxzp1"><strong>更换照片:</strong></td>
			  </tr>
			  <tr>
			    <td height="98" colspan="2" align="left">
			    <s:hidden id="picFileName" name="picFileName" value="" ></s:hidden>
				
			      <table height="68" border="0" align="center" cellpadding="0" cellspacing="0">
			        <tr>
			          <td height="31"><input type="file" name="pic" id="pic" size="40" accept="image/gif,jpg" /></td>
			        </tr>
			        <tr>
			          <td height="16"><span class="STYLE1">文件格式JPG、GIF,个人照片不可超过10K</span></td>
			        </tr>
			        <tr>
			          <td height="21">
			            <input type="button" onclick="javascript:uploadSubmit();" name="" value="保存图片 " class="button" />
			            <input type="button"  value=" 取  消 " onclick="window.close();" />&nbsp;&nbsp;
			            <span id="logoSpan" style="color: red;"></span>
								<%-- 展示错误的字幕	<s:actionerror/> --%>	
						&nbsp;&nbsp;
						<span id="logoErr" style="color: red;"><s:property value="#session.errFileSize"/></span>		
			          </td>
			        </tr>
			      </table>
			      
			        
			     </td>
			  </tr>
		</table>    	
    	
                </td>
              </tr>
            </table>
         
            </td>
            
  <%--   </form>--%>
            
            
          <td width="450" align="left" valign="top">
          
 <%--  <s:form action="userRegister!doModUserInfo.action" name="modUserInfo" id="modUserInfo" method="post">--%>
            <table width="445" height="389" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="90" align="right">姓名：</td>
              <td width="355"><input type="hidden" name="user.userName" value="<s:property value="#session.userObject.userName"/>" />
              <s:property value="#session.userObject.userName"/>
              </td>
            </tr>
            <tr>
            	<input type="hidden" id="picFilePath" name="picFilePath" value='<s:property value="#request.imgIcoPath"/>' />
              <td align="right">所在地区：</td>
              <td class="se">
              	<s:hidden id="userProvince" name="user.province" value="" ></s:hidden>
           		<s:hidden id="userCity" name="user.city" value="" ></s:hidden>
           		<s:hidden id="userZone" name="user.zone" value="" ></s:hidden>
                
		   <s:select name="province" onchange="changeProvinceHandler();" id="province" style="width:20%;"
					list="provinces" headerKey="0" headerValue="请选择..."
					listValue="name" listKey="id" value="sf_id">
			</s:select>
			省
			<s:select id="city" name="city" onchange="changeCityHandler();" headerKey="0" style="width:20%;" headerValue="请选择..."
				    listValue="name" listKey="id" list="cityList" value="cs_id">
			</s:select>
			市
			<s:select id="area" name="area" headerKey="0" style="width:20%;" headerValue="请选择..."
					listValue="name" listKey="id"  list="areaList" value="qy_id">
			</s:select>
			区
      			<font color="red">*&nbsp;</font>
				<br/><span style="color:red" id="areaSpan"></span>
              </td>
            </tr>
            <tr>
              <td align="right">所在公司：</td>
              <td><input type="hidden" name="user.company.companyName" value="<s:property value="#session.userObject.company.companyName"/>" />
              <s:property value="#session.userObject.company.companyName"/>
              </td>
            </tr>
            <tr>
              <td align="right">手机号码：</td>
              <td><input type="hidden" name="user.account" value="<s:property value="#session.userObject.account"/>" />
              <s:property value="#session.userObject.account"/>
              </td>
            </tr>
            <tr>
              <td align="right">电子邮箱：</td>
              <td>
           <%--   <input name="user.email" id="email" type="text" value="<s:property value="#session.userObject.email"/>" style="border:1px solid #DBDBDB; height:20px; color:#626262;" size="20" />--%>
             
              	<s:textfield name="user.email" id="email" size="20" style="border:1px solid #DBDBDB; height:20px; color:#626262;"/>
              	
              	<span style="color:red"  id="emailSpan"></span>
              </td>
            </tr>
            <tr>
              <td align="right">QQ号码：</td>
              <td>
            <%--  <input name="user.qq" id="userQq" type="text" maxlength="11" value="<s:property value="#session.userObject.qq"/>" style="border:1px solid #DBDBDB; height:20px; color:#626262;" size="20" />--%>
              
              	<s:textfield name="user.qq" id="userQq" size="20" maxlength="11" style="border:1px solid #DBDBDB; height:20px; color:#626262;"/>
              
                  <span style="color:red"  id="qqSpan"></span>
              </td>
            </tr>
            <tr>
              <td align="right">个人主页：</td>
              <td>
              <%--<input name="user.personalHonepage" id="personalHonepage" type="text" value="<s:property value="#session.userObject.personalHonepage"/>" style="border:1px solid #DBDBDB; height:20px; color:#626262;" size="20" />
              <s:textfield name="user.personalHonepage" id="personalHonepage" size="20" value="%{#session.userObject.personalHonepage}style="border:1px solid #DBDBDB; height:20px; color:#626262;"/>
              
              --%>
             
              	<s:textfield name="user.personalHonepage" id="personalHonepage" size="20" style="border:1px solid #DBDBDB; height:20px; color:#626262;"/>
              
              <span style="color:red"  id="individualSpan"></span>
              </td>
            </tr>
            <tr>
              <td height="74" align="right" valign="top" style="line-height:23px;">个人介绍：</td>
              <td valign="top"  style="line-height:23px;">
              <input type="hidden" id="hidPersonalIntro" name="hidPersonalIntro" value="<s:property value="#session.userObject.personalIntro"/>" />
               <span class="dx_content2">
             <%-- <textarea name="user.personalIntro" id="personalIntro" cols="18" rows="5" id="grjj">
             		<s:property value="#session.userObject.personalIntro"/></textarea>
             		<s:textarea name="user.personalIntro" cols="18" value="%{#session.userObject.personalIntro}" rows="5" id="personalIntro"/>--%>
                
              		<s:textarea name="user.personalIntro" cols="18" rows="5" id="personalIntro"/>
               
               </span>
               
              </td>
            </tr>
            <tr>
             <td>&nbsp;</td>
             <td><span style="color:red"  id="personalIntroSpan"></span></td>
            </tr>
            <tr>
              <td height="50" colspan="2" align="left">
              <img src="images/bc.jpg" width="92" onclick="javascript:modifyUserInfo();" style="cursor:hand" height="24" />&nbsp;&nbsp;&nbsp;
          <%--     <img src="images/qx1.jpg" width="92" height="24" onclick="javascript:quXiao();" />--%>
              </td>
          </tr></table>
          
     <%-- </s:form>	 --%>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
	</s:form>	
</body>
<script type="text/javascript">
//loadData();
function loadData(){ 
  var email = $.trim($("#hidEmail").val());  //电子邮件
  var qq = $.trim($("#hidQq").val());        //QQ号码
  var personalHonepage = $.trim($("#hidPersonalHonepage").val()); //个人主页
  var personalIntro = $.trim($("#hidPersonalIntro").val());  //个人介绍
  if(email != ""){
  	$("#email").val(email);
  }
  if(qq != ""){
  	$("#userQq").val(qq);
  }
  if(personalHonepage != ""){
  	$("#personalHonepage").val(personalHonepage);
  }
  if(personalIntro != ""){
  	$("#personalIntro").val(personalIntro);
  }
    
}

</script>

</html>
